import { View } from "../../../mvc/core/View";
import { ObjCreate } from "../common/ObjCreate";
import { AvatarUploadPanel } from "../player/AvatarUploadPanel";
import { GModuleEvent } from "../../mvc/GModuleEvent";
import { PlayerRuneFightBtn } from "../player/equip/PlayerRuneFightBtn";
import { EquipmentStrengthAddPanel } from "../player/equip/EquipmentStrengthAddPanel";
import { EquipmentJewelAddPanel } from "../player/equip/EquipmentJewelAddPanel";
import { GuildVipItem } from "../guild/GuildVipItem";
import { ImagesConst } from "../../resource/ImagesConst";
import { ResFileConst } from "../../resource/ResFileConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { EquipsPanel } from "../player/equip/EquipsPanel";
import { GoodsItem } from "../common/GoodsItem";
import { ItemData } from "../../resource/info/ItemData";
import { SPublicMiniPlayer } from "../../../../Message/Public/SPublicMiniPlayer";
import { StatueUserPlayer } from "../../scene/player/entity/StatueUserPlayer";
import { DirectionType } from "../../scene/modle/data/DirectionType";
import { Language } from "../../../../extend/language/Language";
import { SLookupPlayerReply } from "../../../../Message/Game/SLookupPlayerReply";
import { EntityUtil } from "../../scene/layer/utils/EntityUtil";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { UserEquipmentUtil } from "../range/userEquip/UserEquipmentUtil";
import { ColorConfig } from "../../resource/ColorConfig";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { CareerConfig } from "../../resource/CareerConfig";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
type int = number;
//class CityOwnerPanel
    
    export  class CityOwnerPanel extends View
    {
        constructor()
        {
            super();
            this._equipItemArr = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 260, 410, this);
            ObjCreate.createGImageBitmap("RangeBg", 60, 80, this);
            this._avatarUpload = new AvatarUploadPanel();
            this._avatarUpload.x = 10;
            this._avatarUpload.y = 10;
            addChild(this._avatarUpload);
            this._avatarUpload.mode = GModuleEvent.Mode_Other;
            this._runeFight = new PlayerRuneFightBtn();
            this._runeFight.x = 195;
            this._runeFight.y = 10;
            this._runeFight.setRuneLookup(false);
            addChild(this._runeFight);
            this._strengthAddPanel = new EquipmentStrengthAddPanel();
            this._strengthAddPanel.x = 75;
            this._strengthAddPanel.y = 95;
            addChild(this._strengthAddPanel);
            this._strengthAddPanel.mode = GModuleEvent.Mode_Other;
            this._jewelAddPanel = new EquipmentJewelAddPanel();
            this._jewelAddPanel.x = 155;
            this._jewelAddPanel.y = 95;
            addChild(this._jewelAddPanel);
            this._jewelAddPanel.mode = GModuleEvent.Mode_Other;
            this._vipItem = new GuildVipItem();
            this._vipItem.x = 12;
            this._vipItem.y = 60;
            addChild(this._vipItem);
            ObjCreate.createBg(65, 356, 135, 24, this, ImagesConst.SelectedBg);
            ObjCreate.createGLoadedButton(ResFileConst.FightingIcon, 70, 358, 19, 18, this);
            this._fightStrengthTxt = ObjCreate.createGTextField("--", 65, 358, 130, 20, this, new GTextFormat(FontUtil.songtiName, 14, 15788607));
            this._fightStrengthTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._adoreNumTxt = ObjCreate.createGTextField("", 0, 385, 230, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat6));
            ObjCreate.createBitmap(ImagesConst.RangeAdore, 180, 385, this);
            this._nameTf = new GTextFormat("", 13, 15788607);
            this._campTxt = ObjCreate.createGTextField("", 80, 15, 30, 25, this);
            this._nameTxt = ObjCreate.createGTextField("", 110, 15, 100, 25, this, this._nameTf);
            this._level = ObjCreate.createGTextField("", 70, 45, 40, 20, this, GlobalStyle.textFormat2);
            this._career = ObjCreate.createGTextField("", 140, 45, 40, 20, this, GlobalStyle.textFormat2);
            this._levelTxt = ObjCreate.createGTextField("", 105, 45, 40, 20, this, GlobalStyle.textFormat1);
            this._careerTxt = ObjCreate.createGTextField("", 175, 45, 40, 20, this, GlobalStyle.textFormat1);
            this._equipsPanel = new EquipsPanel();
            this._equipsPanel.x = 5;
            this._equipsPanel.y = 55;
            this._equipsPanel.mode = GModuleEvent.Mode_Other;
            this._equipsPanel.setAddPanelVisible(false);
            this._equipsPanel.changeNormalBtn();
            addChild(this._equipsPanel);
            return;
        }

        /* internal  */createEquipItems(): void
        {
            var loc3=null;
            var loc1=13;
            var loc2=90;
            var loc4=0;
            while (loc4 < 18) 
            {
                loc3 = new GoodsItem();
                loc3.setOverPosition(-2, -2);
                loc3.move(loc1, loc2);
                loc3.setSize(33, 33);
                loc3.isDragAble = false;
                loc3.isDropAble = false;
                loc3.toolTipType = ItemData.ToolTipType_Forge;
                addChild(loc3);
                loc3.toolTipType = ItemData.ToolTipType_Pack;
                this._equipItemArr.push(loc3);
                loc2 = loc2 + loc3.height + 10;
                if (loc4 != 5) 
                {
                    if (loc4 != 6) 
                    {
                        if (loc4 != 13) 
                        {
                            if (loc4 != 14) 
                            {
                                if (loc4 != 15) 
                                {
                                    if (loc4 == 16) 
                                    {
                                        loc1 = 13;
                                        loc2 = 350;
                                    }
                                }
                                else 
                                {
                                    loc1 = 165;
                                    loc2 = 305;
                                }
                            }
                            else 
                            {
                                loc1 = 165;
                                loc2 = 262;
                            }
                        }
                        else 
                        {
                            loc1 = 113;
                            loc2 = 305;
                        }
                    }
                    else 
                    {
                        loc1 = 216;
                        loc2 = 90;
                    }
                }
                else 
                {
                    loc1 = 63;
                    loc2 = 305;
                }
                ++loc4;
            }
            return;
        }

        /* internal  */addUserModel(arg1: Map<any, any> /* flash.utils.Dictionary */, arg2: SPublicMiniPlayer, arg3: int, arg4: int): void
        {
            if (this._userModel != null) 
            {
                this._userModel.dispose(false);
            }
            else 
            {
                this._userModel = new StatueUserPlayer();
            }
            this._userModel.direction = DirectionType.South;
            this._userModel.camp = arg2.camp;
            this._userModel.sex = arg2.sex;
            this._userModel.career = arg2.career;
            this._userModel.reserveJs.weaponStPerLv = arg3;
            this._userModel.reserveJs.wingStrPerLv = arg4;
            this._userModel.updateEquipByDic(arg1);
            this._userModel.x = 120;
            this._userModel.y = 260;
            addChildAt(this._userModel, 3);
            return;
        }

        public updateAdoreNum(arg1: int): void
        {
            this._adoreNumTxt.htmlText = Language.getString(36353) + arg1;
            return;
        }

        public updateSTChatelainInfo(arg1: SLookupPlayerReply): void
        {
            var loc1=arg1.miniPlayer;
            if (EntityUtil.isNullEntity(loc1.entityId)) 
            {
                if (this._imgBmp == null) 
                {
                    this._imgBmp = new GImageBitmap(ImagesConst.PlayerAdoreNonOwner, 70, 100);
                }
                addChild(this._imgBmp);
                this.setOwnerVisible(false);
                return;
            }
            this.setOwnerVisible(true);
            if (this._imgBmp && this._imgBmp.parent) 
            {
                removeChild(this._imgBmp);
            }
            if (this._userModel) 
            {
                this._userModel.dispose(false);
            }
            var loc2=UserEquipmentUtil.getEquipmentData(arg1.playerItemUpdates);
            this._equipsPanel.setEquipments(loc2);
            var loc3=UserEquipmentUtil.getUserEquipmentData(loc2, arg1.fashionState, arg1.wingState, arg1.fashionWeaponState, arg1.surroundState, arg1.waistBeltState, arg1.elfState);
            if (!EntityUtil.isNullEntity(loc1.entityId)) 
            {
                this.addUserModel(loc3.equipDic, loc1, loc3.weaponStPerLv, loc3.wingStLv);
            }
            var loc4=ColorConfig.instance.getCountryColor(loc1.camp).intColor;
            var loc5=GameDefConfig.instance.getECamp(loc1.camp);
            this._nameTxt.text = ". " + loc1.name;
            this._nameTxt.setTextFormat(this._nameTf);
            this._campTxt.text = loc5;
            this._campTxt.setTextFormat(new GTextFormat("", 13, loc4));
            this._levelTxt.text = loc1.level.toString();
            this._levelTxt.setTextFormat(GlobalStyle.textFormat1);
            this._careerTxt.text = CareerConfig.instance.getInfoByCode(loc1.career).name;
            this._careerTxt.setTextFormat(GlobalStyle.textFormat1);
            this._level.text = Language.getString(30008);
            this._level.setTextFormat(GlobalStyle.textFormat2);
            this._career.text = Language.getString(30006);
            this._career.setTextFormat(GlobalStyle.textFormat2);
            this._fightStrengthTxt.text = arg1.fight + "";
            this._strengthAddPanel.curCareer = loc1.career;
            this._strengthAddPanel.updateAddInfo();
            this._jewelAddPanel.curCareer = loc1.career;
            this._jewelAddPanel.updateAddInfo();
            this._vipItem.vip = loc1.VIP;
            this._avatarUpload.sex = loc1.sex;
            this._avatarUpload.updateUploadAvatar(loc1.photo, loc1.entityId);
            if (loc1.level >= 65) 
            {
                this._runeFight.updateRuneFight(arg1.runeFight.toString());
            }
            return;
        }

        /* internal  */setOwnerVisible(arg1: Boolean): void
        {
            if (this._runeFight) 
            {
                this._runeFight.visible = arg1;
            }
            if (this._strengthAddPanel) 
            {
                this._strengthAddPanel.visible = arg1;
            }
            if (this._jewelAddPanel) 
            {
                this._jewelAddPanel.visible = arg1;
            }
            return;
        }

        /* internal */ /* var */_avatarUpload: AvatarUploadPanel;

        /* internal */ /* var */_fightStrengthTxt: GTextFiled;

        /* internal */ /* var */_adoreNumTxt: GTextFiled;

        /* internal */ /* var */_strengthAddPanel: EquipmentStrengthAddPanel;

        /* internal */ /* var */_jewelAddPanel: EquipmentJewelAddPanel;

        /* internal */ /* var */_vipItem: GuildVipItem;

        /* internal */ /* var */_runeFight: PlayerRuneFightBtn;

        /* internal */ /* var */_equipItemArr: Array<any>;

        /* internal */ /* var */_campTxt: GTextFiled;

        /* internal */ /* var */_nameTf: GTextFormat;

        /* internal */ /* var */_nameTxt: GTextFiled;

        /* internal */ /* var */_levelTxt: GTextFiled;

        /* internal */ /* var */_careerTxt: GTextFiled;

        /* internal */ /* var */_level: GTextFiled;

        /* internal */ /* var */_career: GTextFiled;

        /* internal */ /* var */_imgBmp: GImageBitmap;

        /* internal */ /* var */_equipsPanel: EquipsPanel;

        /* internal */ /* var */_userModel: StatueUserPlayer;
    }
